/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package newkfp;

import Beans.AddedItem;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.AjaxBehaviorEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
import javax.servlet.http.HttpSession;
import newkfp.util.JsfUtil;
import pojos.Treausry;

/**
 *
 * @author labib.farag
 */
@ManagedBean(name = "billInformationController")
@SessionScoped
public class BillInformation {

    Loger loger;
    @EJB
    private newkfp.LogFacade logFacade;
    @EJB
    private newkfp.TreausryFacade treausryFacade;
    @EJB
    private newkfp.CountryFacade countryFacade;
    private List<String> countries;
    private List<String> factories;
    //represent from 1 to 4 (meat - none meat - cheken etc ..) 
    private int mainItem;
    private String CDate;
    // represent submenue of item selected  
    private String selectedsubItem = "";
    private String selectedCountry = "";
    private String factory = "";
    private double total_Number;
    private double total_price;
    private double totalRow;
    private double unite_price;
    private boolean libra;
    private double totalKg;
    private String customerName = "", customerID;
    private Customer selectedCustomer;
    //// information about bill and balance for Customer 
    private double paied;
    private double discount;
    private boolean noExistence;
    ///// bill information 
    private int billNumber=1;
    private int docNumber=1;
    private double billTotal;
    private double bill_reminder;
    private double balanceAfterBill;
    private String billItemStatus = "Regular";
    private Date billDate = new Date();
    @EJB
    private newkfp.BillFacade ejbFacade;
    @EJB
    private newkfp.BillFacade billFacad;
    @EJB
    private newkfp.BillItemFacade billItemFacad;
    private ArrayList<Quantity_Number> orderList =
            new ArrayList<Quantity_Number>();
    private ArrayList<AddedItem> add_Item =
            new ArrayList<AddedItem>();
    @EJB
    private newkfp.CustomerFacade customerFacad;
    @EJB
    private newkfp.ItemFacade itemFacad;
    private Bill bill;

    public BillInformation() {
        loger = new Loger(getLogFacade());
    }

    public String getBillItemStatus() {
        return billItemStatus;
    }

    public void setBillItemStatus(String billItemStatus) {
        this.billItemStatus = billItemStatus;
    }

    private BillFacade getFacade() {
        return ejbFacade;
    }
    private String customer_status = "";

    public SelectItem[] getItems() {

        List<Item> itemsDB = getFacade().getItems(mainItem);


        HashSet<String> hashSet = new HashSet<String>();
        int i = 1;

        for (Item x : itemsDB) {
            hashSet.add(x.getItemName());
        }
        System.out.println("hashset:" + hashSet.size());
        SelectItem[] items = new SelectItem[hashSet.size() + 1];
        items[0] = new SelectItem("Select Item", "Select Item");
        for (String x : hashSet) {
            System.out.println("Country     " + x);
            items[i++] = new SelectItem(x, x);
        }
        System.out.println("items" + items.length);
        return items;
    }

    public int getMainItem() {
        return mainItem;
    }

    public void setMainItem(int mainItem) {
        this.mainItem = mainItem;
    }

    public String getSelectedsubItem() {
        return selectedsubItem;

    }

    public void setSelectedsubItem(String selectedsubItem) {
        this.selectedsubItem = selectedsubItem;
    }

    public void listenItemchanged(ValueChangeEvent vc) {
        //System.out.println(" value changed ");
        //System.out.println(" subitem is " + selectedsubItem);
    }

    public String getSelectedCountry() {
        return selectedCountry;
    }

    public void setSelectedCountry(String selectedCountry) {
        this.selectedCountry = selectedCountry;
    }

    /// combobox to fill from DB subItem
    public SelectItem[] getCountries() {

        //System.out.println(" selected suItem is " + selectedsubItem);

        List<Item> itemsDB = getFacade().getCountries(selectedsubItem);
        HashSet<Integer> countrys = new HashSet<Integer>();

        int i = 1;
        for (Item x : itemsDB) {
            countrys.add(x.getCountryID().getIdcountry());

        }
        SelectItem[] items = new SelectItem[countrys.size() + 1];
        items[0] = new SelectItem(0, "Select Country");

        for (int x : countrys) {
            Country c = countryFacade.find(x);

            items[i++] = new SelectItem(c.getIdcountry(), c.getCountryName());

        }
        return items;
    }

    public void itemListener(AjaxBehaviorEvent event) {
    }

    /// combobox to fill from DB subItem
    public SelectItem[] getFacoris() {


        SelectItem[] items;
        //System.out.println(" selected country is " + selectedCountry);
        if ("".equals(selectedCountry) || selectedCountry == null) {
            items = new SelectItem[1];
            items[0] = new SelectItem(0, "Select Factory");
        } else {

            List<Item> itemsDB = getFacade().getFactories(selectedsubItem, selectedCountry);
            //System.out.println("   factories : " + itemsDB.size()+1);

            items = new SelectItem[itemsDB.size() + 1];
            int i = 1;
            items[0] = new SelectItem(0, "Select Factory");
            for (Item x : itemsDB) {
                items[i++] = new SelectItem(x.getFactoryID().getIdFactory(), x.getFactoryID().getFactoryName());
            }
        }
        return items;
    }

    public String getFactory() {
        return factory;
    }

    public void setFactory(String factory) {
        this.factory = factory;
    }

    public String meat() {
        mainItem = 1;
        selectedsubItem = "";
        selectedCountry = "";
        return "CustomerBill";
    }

    public String nonMeat() {
        selectedsubItem = "";
        selectedCountry = "";
        mainItem = 2;
        return "CustomerBill";
    }

    public String checken() {
        selectedsubItem = "";
        selectedCountry = "";
        mainItem = 3;
        return "CustomerBill";
    }

    public String vegtable() {
        selectedsubItem = "";
        selectedCountry = "";
        mainItem = 4;
        return "CustomerBill";
    }
    //======================================================================quantity and number of it 
    private int quantity;
    private int number_quantity;

    public int getNumber_quantity() {
        return number_quantity;
    }

    public void setNumber_quantity(int number_quantity) {
        this.number_quantity = number_quantity;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public ArrayList<Quantity_Number> getOrderList() {
        return orderList;
    }

    public double getTotal_Number() {
        return total_Number;
    }

    public void setTotal_Number(double total_Number) {
        this.total_Number = total_Number;
    }

    public double getTotal_price() {
        total_price = 0;
        for (Iterator<Quantity_Number> it = orderList.iterator(); it.hasNext();) {
            Quantity_Number qu = it.next();
            total_price += (unite_price * qu.getNumber() * qu.getQuantity());

        }
        //System.out.println(" --------------"+unite_price +"  ----  "+totalKg);
        //System.out.println("-------------------------in getting  ajax ---------------------"+total_price);
        total_price = unite_price * totalKg;

        return total_price;
    }

    public void setTotal_price(double total_price) {
        this.total_price = total_price;
    }

    public double getUnite_price() {
        return unite_price;
    }

    public void setUnite_price(double unite_price) {
        this.unite_price = unite_price;
    }

    public boolean isLibra() {
        return libra;
    }

    public void setLibra(boolean libra) {
        this.libra = libra;
    }

    /**
     * @return the totalRow
     */
    public double getTotalRow() {
        return quantity * number_quantity;
    }

    /**
     * @param totalRow the totalRow to set
     */
    public void setTotalRow(double totalRow) {
        this.totalRow = totalRow;
    }

    /**
     * @return the totalKg
     */
    public double getTotalKg() {
        return totalKg += getTotalRow();
    }

    /**
     * @param totalKg the totalKg to set
     */
    public void setTotalKg(double totalKg) {
        this.totalKg = totalKg;
    }

    public String calculate() {
        return "Calculation";
    }

    public String finishCalculation() {
        return "CustomerBill";
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public String getCustomerID() {
        return customerID;
    }

    public void setCustomerID(String customerID) {
        this.customerID = customerID;
    }

    public Customer getSelectedCustomer() {
//        System.out.println(" doc number "+getDocNumber()+" request number "+getBillNumber());
        //System.out.println(" : customer Name :"+getCustomerName());
        if (getCustomerName() != null && !getCustomerName().trim().isEmpty()) {
            Customer r = getFacade().getCustomerByName(getCustomerName());
            return selectedCustomer = r;

        } else {

//           JsfUtil.addErrorMessage(ResourceBundle.getBundle("/Bundle").getString("UserNotFound"));
            return null;
        }


    }

    public void setSelectedCustomer(Customer selectedCustomer) {
        this.selectedCustomer = selectedCustomer;
    }

    public ArrayList<AddedItem> getAdd_Item() {
        return add_Item;
    }

    public void setAdd_Item(ArrayList<AddedItem> add_Item) {
        this.add_Item = add_Item;
    }

    public double getDiscount() {
        return discount;
    }

    public void setDiscount(double discount) {
        this.discount = discount;
    }

    public boolean isNoExistence() {
        return noExistence;
    }

    public void setNoExistence(boolean noExistence) {
        this.noExistence = noExistence;
    }

    public double getPaied() {
        return paied;
    }

    public void setPaied(double paied) {
        this.paied = paied;
    }

    public int getBillNumber() {
        return billNumber;
    }

    public void setBillNumber(int billNumber) {
        this.billNumber = billNumber;
    }

    public int getDocNumber() {
        return docNumber;
    }

    public void setDocNumber(int docNumber) {
        this.docNumber = docNumber;
    }

    public double getBalanceAfterBill() {
        if (selectedCustomer != null) {
            return bill_reminder + selectedCustomer.getBalance();
        } else {
            return 0;
        }

    }

    public void setBalanceAfterBill(double balanceAfterBill) {
        this.balanceAfterBill = balanceAfterBill;
    }

    public double getBillTotal() {
        billTotal = 0;
        try {
            for (Iterator<AddedItem> it = add_Item.iterator(); it.hasNext();) {
                AddedItem item = it.next();
                if (item.getBillItemStatus().equalsIgnoreCase("Regular") || item.getBillItemStatus().equalsIgnoreCase("") || item.getBillItemStatus() == null) {
                    billTotal += item.getTotoal_price();
                }
                if (item.getBillItemStatus().equalsIgnoreCase("ProductExecution")) {
                    billTotal -= item.getTotoal_price();
                }
                if (item.getBillItemStatus().equalsIgnoreCase("SalesReturn")) {
                    billTotal -= item.getTotoal_price();
                }
            }
            billTotal = billTotal - discount;
            return billTotal;
        } catch (Exception e) {
            return billTotal;
        }
    }

    public void setBillTotal(double billTotal) {
        this.billTotal = billTotal;
    }

    public double getBill_reminder() {
        //System.out.println(" paid is "+paied   +"bill total "+billTotal  +"");
        bill_reminder = billTotal - paied;
        return bill_reminder;
    }

    public void setBill_reminder(double bill_reminder) {
        this.bill_reminder = bill_reminder;
    }

    //===========================================buttons method ======================================
    public String addAction() {

        int totalAdded = 0;
        for (Iterator<Quantity_Number> it = orderList.iterator(); it.hasNext();) {
            Quantity_Number qu = it.next();
            totalAdded += qu.getQuantity();


        }

        //System.out.println(" total added = " + totalAdded + "TOTAL NUMBER IS = " + total_Number);
        if (!(totalAdded >= total_Number)) {
            Quantity_Number order = new Quantity_Number(quantity, number_quantity, getTotalRow(), getTotalKg());
            orderList.add(order);
        }


        return null;
    }

    public List<String> autocomplete(String inputValue) {
        System.out.println(" input value--------------------------------------------------" + inputValue);
        List<Customer> objList = getFacade().getCustomerByNameOrID(inputValue);
        //System.out.println(" size is " + objList.size());
        List<String> df = new ArrayList<String>();
        if (objList.size() == 0) {


            JsfUtil.addErrorMessage(ResourceBundle.getBundle("/Bundle").getString("UserNotFound"));
            customer_status = "عمي تيارى ل ";

        } else {
            for (Iterator<Customer> it = objList.iterator(); it.hasNext();) {
                Customer emp = it.next();
                //System.out.println(" employees add is "+emp);
                df.add(emp.getCustomerName());
            }
            customer_status = "عميل مسجل ";
        }
        return df;
    }

    public String add_item() {
        try {
            Factory tempFactory = ejbFacade.getFactoryById(Integer.parseInt(factory));
            Country tempCountry = ejbFacade.getCountryById(Integer.parseInt(selectedCountry));
            AddedItem newItem = new AddedItem(tempCountry.getCountryName(), tempFactory.getFactoryName(), selectedsubItem, unite_price, total_price, total_Number, totalKg, null, false, billItemStatus);
            add_Item.add(newItem);
        } catch (Exception ex) {
            JsfUtil.addErrorMessage(ResourceBundle.getBundle("/Bundle").getString("ItemError"));
            return null;

        }
        return null;
    }

    public BillFacade getBillFacad() {
        return billFacad;
    }

    public String commitValues() {
        clearSession();
        if (selectedCustomer == null || selectedCustomer.getCustomerName().trim().length() == 0) {
            JsfUtil.addErrorMessage(ResourceBundle.getBundle("/Bundle").getString("CusromerError"));
            return null;
        }

        List<Bill> bills = billFacad.billCheck(getBillNumber(), getDocNumber(), getBillDate());
        System.out.println("bills---->" + bills);
        if (bills == null || bills.size() == 0) {
            loger = new Loger(getLogFacade());
            // update customer information 
            //System.out.println(" balance after bill added "+getBalanceAfterBill());

            // check bill Number and doc number 

//       boolean test=billFacad.checkDoc_bill_numbers(getDocNumber(),getBillNumber());
//        System.out.println(" Test Bill is"+test);
//       if(!test)
//       {
//              JsfUtil.addErrorMessage( ResourceBundle.getBundle("/Bundle").getString("DocNumber"));
//             return null;
//       }
            // Create Bill 
            Bill newBill = new Bill();
            newBill.setBillCach(paied);
            newBill.setBillNumber(getBillNumber());    // should not be constant 
            newBill.setBillReminder(bill_reminder);
            newBill.setBillTotal(billTotal);
            newBill.setCreateDate(billDate);
            newBill.setCustomerID(selectedCustomer);
            newBill.setDisCount(discount);
            newBill.setDocNum(getDocNumber());                    /// unknown
            newBill.setExporterID(new Exporter(-1));
            newBill.setTempFlag(1);
            if (noExistence) {
                newBill.setNonexistentFlag(1);                  /////     
            } else {
                newBill.setNonexistentFlag(0);                  ///// 
            }
            billFacad.create(newBill);

            /// Loop Over Bill Add in last table 
            for (Iterator<AddedItem> it = add_Item.iterator(); it.hasNext();) {
                AddedItem billitem = it.next();

                //System.out.println(" factory is--------------- "+billitem.getFactory()+"");
                Factory tempfactory = ejbFacade.getFactoryByName(billitem.getFactory());

                //System.out.println(" country is--------------- "+billitem.getCountry()+"");
                Country tempcountry = ejbFacade.getCountryByName(billitem.getCountry());
                Item item = getFacade().getItemByFactoryAndCountry(billitem.getItem(), tempfactory);


                /// updating Item amount 
//            item.setPk_Count(item.getPk_Count()-billitem.getItem_quantity());
//            item.setQuantity(item.getQuantity()-billitem.getItem_count());


               // itemFacad.edit(item);

                BillItem newBillItem = new BillItem();
                newBillItem.setBillID(newBill);
                newBillItem.setFactoryID(tempfactory);
                newBillItem.setItemAmount(billitem.getItem_quantity());
                newBillItem.setItemPrice(billitem.getUnit_price());
                newBillItem.setPackageCount(billitem.getItem_count());
                newBillItem.setTotalPrice(billitem.getTotoal_price());
                newBillItem.setItemID(item);
                newBillItem.setExportBill(0);
                //System.out.println("BillItemStatus is: "+billitem.getBillItemStatus());
                newBillItem.setBillItemStatus(billitem.getBillItemStatus());
                billItemFacad.create(newBillItem);
            }

//           selectedCustomer.setBalance(getBalanceAfterBill());
//        customerFacad.edit(selectedCustomer);
            String s = "تم اضافة فاتوره رقم ";
            String sd = "دفتر رقم ";
            String ss = " جديده للعميل رقم :";
            String t = "باجمالي : ";
            String d = "في تاريخ";
            loger.LogerString(s + newBill.getBillNumber() + sd + newBill.getDocNum() + ss + selectedCustomer.getCustomerName() + "  " + d + " " + newBill.getCreateDate() + " " + t + newBill.getBillTotal(), 0);

            ////////////////////////REST VALUES 




            clear();
            billNumber++;

//            docNumber=(billNumber%50)+1;
        } else {
            JsfUtil.addErrorMessage(ResourceBundle.getBundle("/Bundle").getString("Billadderror"));
        }
        return null;
    }

    public String confirmValues() {
        loger = new Loger(getLogFacade());

        // Create Bill 
        Bill bill = getBill();
        bill.setBillCach(paied);
        bill.setBillNumber(billNumber);
        bill.setBillReminder(bill_reminder);
        bill.setBillTotal(billTotal);
        bill.setCreateDate(billDate);
        bill.setCustomerID(selectedCustomer);
        bill.setDisCount(discount);
        bill.setDocNum(docNumber);
        bill.setExporterID(new Exporter(-1));
        bill.setTempFlag(0);
        if (noExistence) {
            bill.setNonexistentFlag(1);
        } else {
            bill.setNonexistentFlag(0);
        }
        billFacad.edit(bill);

        //remove from bill_item
        for (BillItem billItem : billItemFacad.getBillItems(bill.getIdBill())) {
            billItemFacad.remove(billItem);
        }

        //Loop Over Bill Add in last table 
        for (Iterator<AddedItem> it = add_Item.iterator(); it.hasNext();) {
            AddedItem billitem = it.next();
            Factory tempfactory = ejbFacade.getFactoryByName(billitem.getFactory());
            Item item = getFacade().getItemByFactoryAndCountry(billitem.getItem(), tempfactory);

            if (billitem.getBillItemStatus().equalsIgnoreCase("WithoutValue") || billitem.getBillItemStatus().equalsIgnoreCase("ProductExecution")) {
                // updating Item number of packages  
                item.setPk_Count(item.getPk_Count());
                // updating item quantity
                item.setQuantity(item.getQuantity());
                //adjusting customer balance
                //selectedCustomer.setBalance(selectedCustomer.getBalance()+billitem.getTotoal_price());
            }
            if (billitem.getBillItemStatus().equalsIgnoreCase("SalesReturn")) {
                // updating Item number of packages 
                item.setPk_Count(item.getPk_Count() + billitem.getItem_count());
                // updating item quantity
                item.setQuantity(item.getQuantity() + billitem.getItem_quantity());
                //adjusting customer balance
                // selectedCustomer.setBalance(selectedCustomer.getBalance()+billitem.getTotoal_price());
            }
            if (billitem.getBillItemStatus().equalsIgnoreCase("Regular") || billitem.getBillItemStatus().equalsIgnoreCase("") || billitem.getBillItemStatus() == null) {
                // updating Item number of packages 
                item.setPk_Count(item.getPk_Count() - billitem.getItem_count());
                // updating item quantity
                item.setQuantity(item.getQuantity() - billitem.getItem_quantity());
            }
            itemFacad.edit(item);

            BillItem newBillItem = new BillItem();
            newBillItem.setBillID(bill);
            newBillItem.setFactoryID(tempfactory);
            newBillItem.setItemAmount(billitem.getItem_quantity());
            newBillItem.setItemPrice(billitem.getUnit_price());
            newBillItem.setPackageCount(billitem.getItem_count());
            newBillItem.setTotalPrice(billitem.getTotoal_price());
            newBillItem.setItemID(item);
            newBillItem.setExportBill(0);
            newBillItem.setBillItemStatus(billitem.getBillItemStatus());
            billItemFacad.create(newBillItem);
        }

        //update customer information
        selectedCustomer.setBalance(getBalanceAfterBill());
        customerFacad.edit(selectedCustomer);

        //logging
        String s = "تم تاكيد فاتوره رقم ";
        String sd = "دفتر رقم ";
        String ss = "  للعميل رقم :";
        String t = "باجمالي : ";
        String d = "في تاريخ";
        loger.LogerString(s + bill.getBillNumber() + sd + bill.getDocNum() + ss + selectedCustomer.getCustomerName() + "  " + d + " " + getCDate() + " " + t + bill.getBillTotal(), 0);

        HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);

        //saving action details into  treasury
        Treausry treausry = new Treausry();
        treausry.setActionDate(billDate);
        treausry.setCustomerId(selectedCustomer);
        treausry.setEmployeeId(new Employee(Integer.parseInt(session.getValue("empid").toString())));
        treausry.setExporterId(null);
        treausry.setGeneralDescription(s + bill.getBillNumber() + sd + bill.getDocNum() + ss + selectedCustomer.getCustomerName());
        treausry.setMoneyAmount(bill.getBillCach());
        treausry.setBillId(bill);
        treausryFacade.create(treausry);

        clear();
        clearSession();
        return "confirmBills";
    }

    public String testAjax() {
        //System.out.println(" excuting ajax ");
        return "";
    }

    public String deleteAction(AddedItem order) {

        add_Item.remove(order);
        return null;
    }

    public CustomerFacade getCustomerFacad() {
        return customerFacad;
    }

    /**
     * @return the CDate
     */
    public String getCDate() {
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
        System.out.println("billDate:" + billDate);
        CDate = dateFormat.format(billDate);
        return CDate;
    }

    /**
     * @param CDate the CDate to set
     */
    public void setCDate(String CDate) {
        this.CDate = CDate;
    }

    public String calculateTotalOnBlur() {
        total_price = unite_price * number_quantity;
        //System.out.println(" total prise is "+total_price);
        return null;
    }

    public String editAction(AddedItem order) {

        order.setEditable(true);
        return null;
    }

    public String saveAction(AddedItem order2) {
        System.out.println("list:" + order2.getItem_quantity());
        //get all existing value but set "editable" to false 
        order2.setTotoal_price(order2.getUnit_price() * order2.getItem_quantity());
        for (AddedItem order : add_Item) {

            order.setEditable(false);
        }

        //return to current page
        return null;

    }

    public String getCustomer_status() {
        return customer_status;
    }

    public void setCustomer_status(String customer_status) {
        this.customer_status = customer_status;
    }

    public Bill getBill() {
        return bill;
    }

    public void setBill(Bill bill) {
        this.bill = bill;
    }

    public LogFacade getLogFacade() {
        return logFacade;
    }

    public void setLogFacade(LogFacade logFacade) {
        this.logFacade = logFacade;
    }

    public TreausryFacade getTreausryFacade() {
        return treausryFacade;
    }

    public void setTreausryFacade(TreausryFacade treausryFacade) {
        this.treausryFacade = treausryFacade;
    }

    public void clear() {
        selectedCustomer = null;
        add_Item.clear();
        balanceAfterBill = 0.0;
        // billNumber++;
        billTotal = 0.0;
        bill_reminder = 0.0;
        customerName = "";
        discount = 0.0;
        noExistence = false;
        unite_price = 0.0;
        totalKg = 0.0;
        total_Number = 0.0;
        number_quantity = 0;
        balanceAfterBill = 0.0;
        paied = 0.0;
        selectedCountry = "";
        selectedsubItem = "";
    }

    public Date getBillDate() {
        return billDate;
    }

    public void setBillDate(Date billDate) {
        this.billDate = billDate;
    }

    public CountryFacade getCountryFacade() {
        return countryFacade;
    }

    public void setCountryFacade(CountryFacade countryFacade) {
        this.countryFacade = countryFacade;
    }

    public void clearSession() {
        Map m = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
        m.remove("exporterController");

//m.remove("employeeController"); 
        m.remove("customerController");
        m.remove("countryController");
//m.remove("billInformationController"); 
        m.remove("inventoryStoreController");
        m.remove("moneyController");
        m.remove("billConfirmController");
        m.remove("billExporterInformationController");
        m.remove("logController");
        m.remove("itemController");

    }
    public void error(){
 billNumber=1;
 docNumber=1;
}
}
